package com.pgytesting.secondhandcar.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.pgytesting.secondhandcar.model.ContractMaterial;
import com.pgytesting.secondhandcar.model.CreditInformation;
import com.pgytesting.secondhandcar.model.LoanInformation;
import com.pgytesting.secondhandcar.model.LoanMaterial;
import com.pgytesting.secondhandcar.model.LoanRepaymentInformation;
import com.pgytesting.secondhandcar.model.McpCarDealerInformation;
import com.pgytesting.secondhandcar.model.McpUserInfo;
import com.pgytesting.secondhandcar.model.PhotographingMaterial;
import com.pgytesting.secondhandcar.model.ReviewInformation;
import com.pgytesting.secondhandcar.model.ServiceInformation;
import com.pgytesting.secondhandcar.model.SupplementaryBasicInformation;
import com.pgytesting.secondhandcar.model.VehicleInformation;
import com.pgytesting.secondhandcar.service.ContractMaterialService;
import com.pgytesting.secondhandcar.service.CreditInformationService;
import com.pgytesting.secondhandcar.service.LoanInformationService;
import com.pgytesting.secondhandcar.service.LoanMaterialService;
import com.pgytesting.secondhandcar.service.LoanRepaymentInformationService;
import com.pgytesting.secondhandcar.service.McpCarDealerInformationService;
import com.pgytesting.secondhandcar.service.McpUserInfoService;
import com.pgytesting.secondhandcar.service.PhotographingMaterialService;
import com.pgytesting.secondhandcar.service.ServiceInformationService;
import com.pgytesting.secondhandcar.service.SupplementaryBasicInformationService;
import com.pgytesting.secondhandcar.service.VehicleInformationService;
import com.pgytesting.secondhandcar.vo.ResponseMessage;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/admin/orderInformation")
public class OrderInformationController {

	@Autowired
	private McpUserInfoService mcpUserInfoService;//用户
	@Autowired
	private McpCarDealerInformationService mcpCarDealerInformationService;//销售
	@Autowired
	private VehicleInformationService vehicleInformationService;//车辆
	@Autowired
	private SupplementaryBasicInformationService supplementaryBasicInformationService;//补充基本信息
	@Autowired
	private CreditInformationService creditInformationService;//征信
	@Autowired
	private ServiceInformationService serviceInformationService;//服务信息
	@Autowired
	private PhotographingMaterialService photographingMaterialService;//合影材料
	@Autowired
	private LoanRepaymentInformationService loanRepaymentInformationService;//贷款还款信息
	@Autowired
	private ContractMaterialService contractMaterialService;//合同信息
	@Autowired
	private LoanMaterialService loanMaterialService;//放款材料
	
	/**
	 * 获取用户信息详情
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getUserDetail",method = RequestMethod.POST)
	public ResponseMessage getUserDetail(@RequestBody McpUserInfo mcpUserInfo) {
		try {
			return ResponseMessage.successResponse(mcpUserInfoService.queryUserDetail(mcpUserInfo));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取用户详情出现异常");
		}
	}
	
	/**
	 * 获取销售信息详情
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getSaleDetail",method = RequestMethod.POST)
	public ResponseMessage getSaleDetail(@RequestBody McpCarDealerInformation mcpCarDealerInformation) {
		try {
			return ResponseMessage.successResponse(mcpCarDealerInformationService.queryByUserNumber(mcpCarDealerInformation.getUserNumber()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取销售详情出现异常");
		}
	}
	
	/**
	 * 获取车辆信息详情
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getVehicleDetail",method = RequestMethod.POST)
	public ResponseMessage getVehicleDetail(@RequestBody VehicleInformation vehicleInformation) {
		try {
			return ResponseMessage.successResponse(vehicleInformationService.queryVehicleDetail(vehicleInformation));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取销售详情出现异常");
		}
	}
	
	/**
	 * 获取用户补充的基本信息
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getSupplementaryInformation",method = RequestMethod.POST)
	public ResponseMessage getSupplementaryInformation(@RequestBody SupplementaryBasicInformation supplementaryBasicInformation) {
		try {
			return ResponseMessage.successResponse(supplementaryBasicInformationService.querySupplementaryInformation(supplementaryBasicInformation));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取用户补充的基本信息出现异常");
		}
	}
	
	/**
	 * 获取用户征信查询授权信息
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getCreditInformation",method = RequestMethod.POST)
	public ResponseMessage getCreditInformation(@RequestBody CreditInformation creditInformation) {
		try {
			return ResponseMessage.successResponse(creditInformationService.queryById(creditInformation.getId()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取征信信息出现异常");
		}
	}
	
	/**
	 * 获取服务信息
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getServiceInformation",method = RequestMethod.POST)
	public ResponseMessage getServiceInformation(@RequestBody ServiceInformation serviceInformation) {
		try {
			return ResponseMessage.successResponse(serviceInformationService.queryById(serviceInformation.getId()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取服务信息出现异常");
		}
	}
	
	/**
	 * 获取合影材料信息
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getphotographingMaterial",method = RequestMethod.POST)
	public ResponseMessage getphotographingMaterial(@RequestBody PhotographingMaterial photographingMaterial) {
		try {
			return ResponseMessage.successResponse(photographingMaterialService.queryById(photographingMaterial.getId()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取合影材料出现异常");
		}
	}
	
	/**
	 * 获取贷款还款信息
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getLoanRepaymentInformation",method = RequestMethod.POST)
	public ResponseMessage getLoanInformation(@RequestBody LoanRepaymentInformation loanRepaymentInformation) {
		try {
			return ResponseMessage.successResponse(loanRepaymentInformationService.queryById(loanRepaymentInformation.getId()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取贷款还款信息出现异常");
		}
	}
	
	/**
	 * 获取合同材料
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getContractMaterial",method = RequestMethod.POST)
	public ResponseMessage getContractMaterial(@RequestBody ContractMaterial contractMaterial) {
		try {
			return ResponseMessage.successResponse(contractMaterialService.queryById(contractMaterial.getId()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取合同材料出现异常");
		}
	}
	
	/**
	 * 获取放款材料
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getLoanMaterial",method = RequestMethod.POST)
	public ResponseMessage getLoanMaterial(@RequestBody LoanMaterial loanMaterial) {
		try {
			return ResponseMessage.successResponse(loanMaterialService.queryById(loanMaterial.getId()));		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取放款材料出现异常");
		}
	}
}
